<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>滑动文字效果</title>
    <style>
        body {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
        }

        .slider {
            position: relative;
            width: 80%;
            max-width: 600px;
            height: 100px;
            overflow: hidden;
            text-align: center;
            line-height: 100px;
            font-size: 24px;
            color: #333;
        }

        .slide {
            position: absolute;
            width: 100%;
            opacity: 0;
            transition: opacity 1s ease-in-out;
        }

        .slide.active {
            opacity: 1;
        }
    </style>
</head>

<body>
    <div class="slider">
        <div class="slide active">这是一个由我个人独立开发的在线 OJ 平台</div>
        <div class="slide">请登录或注册以开始使用</div>
        <div class="slide">欢迎加入我们的社区！</div>
    </div>

    <script>
        let slides = document.querySelectorAll('.slide');
        let currentIndex = 0;

        function showSlide(index) {
            slides.forEach((slide, idx) => {
                slide.classList.remove('active');
                if (idx === index) {
                    slide.classList.add('active');
                }
            });
        }

        setInterval(() => {
            currentIndex = (currentIndex + 1) % slides.length;
            showSlide(currentIndex);
        }, 3000); // 3000毫秒切换一次
    </script>
</body>

</html>